extends Control

var isOpen:bool=false:
	set(v):
		if v:get_tree().paused=true
		else:get_tree().paused=false
		isOpen=v
		visible=v

@onready var bag:Bag=preload('res://背包/背包.tres')
@onready var showItems:Array=$NinePatchRect/GridContainer.get_children()


func _ready() -> void:
	isOpen=false
	update()
	bag.updated.connect(update)

func _input(event: InputEvent) -> void:
	if event.is_action_pressed('切换背包'):
		isOpen=!isOpen

func update():
	for i in range(min(bag.cells.size(),showItems.size())):
		showItems[i].update(bag.cells[i])
